package com.gree.scmservice.dao;

import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class SysUserDao {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    Dao dao;

    public String getPassword(String usid){
        String sqlStr = "select * from smbse01400 where usid=@usid";
        Sql sql = Sqls.create(sqlStr);
        sql.setParam("usid",usid);
        sql.setCallback(Sqls.callback.records());
        List<Record> records = dao.execute(sql).getList(Record.class);
        if (records.size()>0){
            return records.get(0).getString("pawd");
        }else {
            return "";
        }
    }
}
